package com.study.listener;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 接收消息
 */
@Component
@Slf4j
public class SimpleListener {

    @RabbitListener(queues = "hello.queue")
    public void listenAddFavoriteCountsSuccess(String s){
        System.out.println("message:"+s);
        throw  new RuntimeException("test exception");
    }

    @RabbitListener(queues = "work.queue")
    public void workQueue1(String s) throws InterruptedException {
        System.out.println("message---1---:"+s);
        Thread.sleep(20);
    }

    @RabbitListener(queues = "work.queue")
    public void workQueue2(String s) throws InterruptedException {
        System.err.println("message---2---:"+s);
        Thread.sleep(20);
    }
}
